home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Code Resources / CDEF - DeBugger 2.0.2 / Window-Main.c < prev   
Encoding:
Text File  |  1995-10-19  |  2.5 KB  |  80 lines  |  [TEXT/KAHL]

  1. // Prototypes
  2.     void     DrawMyWindow( void );
  3.     void    UpdateMainWindow( WindowPtr theWindow );
  4.  
  5. // Globals
  6.     Main            myMain;
  7.  
  8. /******************************************************************
  9.  
  10.     Create the main window and any additional items that need
  11.     initialization.
  12.     
  13. ******************************************************************/
  14. void     DrawMyWindow( void )
  15. {
  16.     Rect        theRect;
  17.     short        cntlID, variation;
  18.     CntlParam    myParam;
  19.     
  20.     // create our window and give it a real catchy name.
  21.         SetRect( &theRect, 20, 60, 300, 200 );
  22.         myMain.window = NewCWindow( nil, &theRect, "\pCDEF - DeBugger v2.0.1", 1, 0, (WindowPtr)-1, 1, MAIN_WINDOW );
  23.         SetPort( myMain.window );
  24.     
  25.     // create our control and store it in our window struct
  26.         cntlID         = 128;
  27.         variation     = 0;
  28.         SetRect( &theRect, (*myMain.window).portRect.left + 20, (*myMain.window).portRect.top + 60,
  29.                            (*myMain.window).portRect.right - 20, (*myMain.window).portRect.top + 76 );
  30.     
  31.     // set up the parameters for our control
  32.         myParam.theWindow      = myMain.window;
  33.         myParam.cntlRect       = theRect;
  34.         myParam.title[0]       = 0x00;
  35.         myParam.visible       = true;
  36.         myParam.initialValue = 0;
  37.         myParam.min             = -360;
  38.         myParam.max          = 360;
  39.         myParam.cntlType     = ( cntlID * 16 ) + variation;
  40.     
  41.     // now let's set up our funky control
  42.         SetUpMyControl( myParam );
  43.     
  44.     // for kicks I also provided apples standard scroll bar.
  45.         SetRect( &theRect, (*myMain.window).portRect.left + 20, (*myMain.window).portRect.top + 100,
  46.                            (*myMain.window).portRect.right - 20, (*myMain.window).portRect.top + 116 );
  47.         myMain.hAppleControl = NewControl( myMain.window, &theRect, "\p", 1, 0, -360, 360, 16, 0L );
  48.     
  49.     // Update the window
  50.         UpdateMainWindow( myMain.window );
  51. }
  52.  
  53. /******************************************************************
  54.  
  55.     Draw the main window.
  56.     
  57. ******************************************************************/
  58. void    UpdateMainWindow( WindowPtr theWindow )
  59. {
  60.     Rect        winRect = (*theWindow).portRect;
  61.     short         strWidth, winCenter;
  62.     Str255        theString = "\pYou should see a swell CDEF at this point.";
  63.     
  64.     // first erase the window.
  65.         EraseRect( &winRect );
  66.     
  67.     // draw your controls
  68.         DrawControls( myMain.window );
  69.     
  70.     // Add a message to remind yourself.. "Hey I should see my CDEF at this point"
  71.     // in case your just staring at a blank window.
  72.         TextFont( 9 );
  73.         TextSize( 9 );
  74.         strWidth = StringWidth( theString );
  75.         winCenter = ( winRect.right - winRect.left ) / 2;
  76.         MoveTo( winCenter - ( strWidth / 2 ), 20 );
  77.         DrawString( theString );
  78.         TextFont( 0 );
  79.         TextSize( 12 );
  80. }